﻿using System;
using System.Web.Services;
using System.Diagnostics;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Xml.Serialization;

namespace com.huawei.esdk.tp.professional.eSDKPlatformKeyMgrService
{
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="PlatformKeyMgrServiceSoapBinding", Namespace="esdk_platform")]
    public partial class PlatformKeyMgrService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        private System.Threading.SendOrPostCallback setSecretKeyOperationCompleted;
        
        private System.Threading.SendOrPostCallback getPublicKeyOperationCompleted;
        
        //private bool useDefaultCredentialsSetExplicitly;
        
        /// <remarks/>
        public PlatformKeyMgrService() {
            this.Url = "http://localhost:8080/";
        }

        public PlatformKeyMgrService(string url)
        {
            this.Url = url;
        }

        //public new string Url {
        //    get {
        //        return base.Url;
        //    }
        //    set {
        //        if ((((this.IsLocalFileSystemWebService(base.Url) == true) 
        //                    && (this.useDefaultCredentialsSetExplicitly == false)) 
        //                    && (this.IsLocalFileSystemWebService(value) == false))) {
        //            base.UseDefaultCredentials = false;
        //        }
        //        base.Url = value;
        //    }
        //}
        
        //public new bool UseDefaultCredentials {
        //    get {
        //        return base.UseDefaultCredentials;
        //    }
        //    set {
        //        base.UseDefaultCredentials = value;
        //        this.useDefaultCredentialsSetExplicitly = true;
        //    }
        //}
        
        /// <remarks/>
        public event setSecretKeyCompletedEventHandler setSecretKeyCompleted;
        
        /// <remarks/>
        public event getPublicKeyCompletedEventHandler getPublicKeyCompleted;
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("esdk_platformsetSecretKey", RequestNamespace="esdk_platform", ResponseNamespace="esdk_platform", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        [return: System.Xml.Serialization.XmlElementAttribute("resultCode", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public int setSecretKey([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string secretType, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string secretKey, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string iv) {
            object[] results = this.Invoke("setSecretKey", new object[] {
                        secretType,
                        secretKey,
                        iv});
            return ((int)(results[0]));
        }
        
        /// <remarks/>
        public void setSecretKeyAsync(string secretType, string secretKey, string iv) {
            this.setSecretKeyAsync(secretType, secretKey, iv, null);
        }
        
        /// <remarks/>
        public void setSecretKeyAsync(string secretType, string secretKey, string iv, object userState) {
            if ((this.setSecretKeyOperationCompleted == null)) {
                this.setSecretKeyOperationCompleted = new System.Threading.SendOrPostCallback(this.OnsetSecretKeyOperationCompleted);
            }
            this.InvokeAsync("setSecretKey", new object[] {
                        secretType,
                        secretKey,
                        iv}, this.setSecretKeyOperationCompleted, userState);
        }
        
        private void OnsetSecretKeyOperationCompleted(object arg) {
            if ((this.setSecretKeyCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.setSecretKeyCompleted(this, new setSecretKeyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("esdk_platformgetPublicKey", RequestNamespace="esdk_platform", ResponseNamespace="esdk_platform", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        [return: System.Xml.Serialization.XmlElementAttribute("resultCode", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public int getPublicKey([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string secretType, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out string publicKey) {
            object[] results = this.Invoke("getPublicKey", new object[] {
                        secretType});
            publicKey = ((string)(results[1]));
            return ((int)(results[0]));
        }
        
        /// <remarks/>
        public void getPublicKeyAsync(string secretType) {
            this.getPublicKeyAsync(secretType, null);
        }
        
        /// <remarks/>
        public void getPublicKeyAsync(string secretType, object userState) {
            if ((this.getPublicKeyOperationCompleted == null)) {
                this.getPublicKeyOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetPublicKeyOperationCompleted);
            }
            this.InvokeAsync("getPublicKey", new object[] {
                        secretType}, this.getPublicKeyOperationCompleted, userState);
        }
        
        private void OngetPublicKeyOperationCompleted(object arg) {
            if ((this.getPublicKeyCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.getPublicKeyCompleted(this, new getPublicKeyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        public new void CancelAsync(object userState) {
            base.CancelAsync(userState);
        }
        
        private bool IsLocalFileSystemWebService(string url) {
            if (((url == null) 
                        || (url == string.Empty))) {
                return false;
            }
            System.Uri wsUri = new System.Uri(url);
            if (((wsUri.Port >= 1024) 
                        && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
                return true;
            }
            return false;
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")]
    public delegate void setSecretKeyCompletedEventHandler(object sender, setSecretKeyCompletedEventArgs e);
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class setSecretKeyCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal setSecretKeyCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public int Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((int)(this.results[0]));
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")]
    public delegate void getPublicKeyCompletedEventHandler(object sender, getPublicKeyCompletedEventArgs e);
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class getPublicKeyCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal getPublicKeyCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public int Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((int)(this.results[0]));
            }
        }
        
        /// <remarks/>
        public string publicKey {
            get {
                this.RaiseExceptionIfNecessary();
                return ((string)(this.results[1]));
            }
        }
    }
}
